package com.bonc.modules.dial.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bonc.datasource.annotation.DataSource;
import com.bonc.modules.dial.dao.DialTestProdtCodeDao;
import com.bonc.modules.dial.entity.DialTestProdtCode;
import com.bonc.modules.dial.service.DialTestProdtCodeService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@DataSource("data")
@Service
public class DialTestProdtCodeServiceImple extends ServiceImpl<DialTestProdtCodeDao, DialTestProdtCode> implements DialTestProdtCodeService {

    @Override
    public List<DialTestProdtCode> queryDialTestProdtCode(DialTestProdtCode dialTestProdtCodeParam){

        LambdaQueryWrapper<DialTestProdtCode> queryWrapper = new LambdaQueryWrapper<>();
        if(ObjectUtil.isNotEmpty(dialTestProdtCodeParam.getIsZy())){
            queryWrapper.eq(DialTestProdtCode::getIsZy, dialTestProdtCodeParam.getIsZy());
        }
        if(ObjectUtil.isNotEmpty(dialTestProdtCodeParam.getProdtTypeCode())){
            queryWrapper.eq(DialTestProdtCode::getProdtTypeCode, dialTestProdtCodeParam.getProdtTypeCode());
        }
        if(ObjectUtil.isNotEmpty(dialTestProdtCodeParam.getZyProdtCode())){
            queryWrapper.eq(DialTestProdtCode::getZyProdtCode, dialTestProdtCodeParam.getZyProdtCode());
        }
        queryWrapper.orderByAsc(DialTestProdtCode::getProdtCode);
        return baseMapper.selectList(queryWrapper);
    }
}
